
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { ApiService } from 'src/app/core/api';

@Injectable()
export class IndexActivate implements Resolve<any> {
	constructor(private apiService: ApiService) { }
	// list: Array<any> = [
	// 	{image:'../../../assets/images/index/xmxx.png',uri:'1',title:'消滅星星',text:'どうぶつの森 ポケット'},
	// 	{image:'../../../assets/images/index/listIMG2.png',uri:'2',title:'色彩跳跃',text:'どうぶつの森 ポケット'},
	// 	{image:'../../../assets/images/index/listIMG3.png',uri:'http://139.196.218.92:4212/popstar.html',title:'どうぶつの森 ポケ',text:'どうぶつの森 ポケット'},
	// 	{image:'../../../assets/images/index/listIMG4.png',uri:'http://139.196.218.92:4212/popstar.html',title:'どうぶつの森 ポケ',text:'どうぶつの森 ポケット'},
	// 	{image:'../../../assets/images/index/listIMG5.png',uri:'3',title:'帝国战绩',text:'重度ARPG类H5游戏'},
	// 	{image:'../../../assets/images/index/listIMG6.png',uri:'http://139.196.218.92:4212/popstar.html',title:'どうぶつの森 ポケ',text:'どうぶつの森 ポケット'},
	// 	{image:'../../../assets/images/index/listIMG7.png',uri:'4',title:'乒乓之王',text:'どうぶつの森 ポケット'},
	// 	{image:'../../../assets/images/index/listIMG8.png',uri:'http://139.196.218.92:4212/popstar.html',title:'どうぶつの森 ポケ',text:'どうぶつの森 ポケット'},
	// ]
	indexData = {
		gamelist: [
			{
				"id": 1,
				"name": "第一台球",
				"type": "H5Game",
				"genreId": 8,
				"genreName": "其它",
				"isOnline": "N",
				"levelStar": 3.0,
				"briefInfo": "世界第一台球",
				"thumbnail": "http://127.0.0.1:8213\\41582280523494154989662.jpg",
				"startCount": 0,
				"viewCount": 0,
				"createTime": "2020-02-22 19:00:47"
			}
		],
		beforPlays: [
			{
				"relationType": "Game",    // Game 游戏  Cartoon 漫画
				"productId": 1000,         // id
				"productName": "LOL",      // 名称
				"thumbnail": "http://127.0.0.1:8213\\game\\2020-02-20\\14\\05c613277bc14d0982e57dcff24fbfcf.jpg"
			}                               // 图片
		],
		banner: [
			{
				id: 2,
				image: "http://127.0.0.1:8213\\abc.jpg",
				relationType: "Game", // Game游戏，Cartoon漫画
				productId: 1 // 产品编号（游戏，漫画）
			}
		]
	};
	resolve() {
		// return this.list;
		let data = {
			pageNo: 1,
			genreId: '',
			gameName: '',
			gameType: ''
		}


		return this.apiService.post('游戏列表', data).then(res => {
			// this.indexData.gamelist = res['data']['list'];
			this.apiService.post('最近在玩', {}).then(res => {
				// this.indexData.beforPlays = res['data']['list'];
				this.apiService.post('首页产品推荐列表(首页轮播图)', {}).then(res => {
					// this.indexData.banner = res['data']['list'];
					return this.indexData;
				})
			})
		}).catch(res => {
			return res;
		});
	}
}
